package tennos;

import static mathUtils.VecMath.*;
import integration.Integrable;
import integration.IntegrableSystem;

public class FakeSolarSystem extends IntegrableSystem {
	
	public void findSlope() {
		super.findSlope();
		for (Integrable e : elementList) {
			float a[] = e.dstate()[e.dstate().length-1];
			float x[] = e.state()[0];
			float r3 = vecMag(x)*vecMag2(x);
			vecZero(a);
			vecAddScaled(a, x, -1/r3, a);
		}
	}
	
	public float energy() {
		float en = 0;
		for (Integrable e : elementList) {
			en += 0.5f*1.0f*vecMag2(e.state()[1]);
			en -= 1.0f/vecMag(e.state()[0]);
		}		
		return en;		
	}
}
